home *** CD-ROM | disk | FTP | other *** search
- // ============================================================================
- // TUTORIAL 2
- //
- // The script implements tutorial nr 2.
- //
- // Topic :
- // - Building complex production
- // - Playing with production parameters
- // ============================================================================
-
- // ============================================================================
- // VARIABLES
- // ============================================================================
-
- [VARIABLES]
-
- // Parameter variables.
- ReturnState$
- FirstTutorialTextID
- LastTutorialTextID
- TutorialTextID
-
- // Helper variables.
- Local_i
-
- // Building IDs
- ShopID
- BuildingFactoryID
- MineID
- StoragePlace1ID
- SteelMillID
- LoggingCampID
- SawMillID
- StoragePlace2ID
-
- // Production IDs
- MineProductionSet
- SteelMillProductionSet
- LoggingCampProductionSet
- SawMillProductionSet
-
- // ============================================================================
- // INIT
- // ============================================================================
- [STATE Load]
-
- LoadGame("missions\\00_01_Tutorial 2_1900.ig2")
- LoadMissionConfig("missions\\00_01_Tutorial 2_1900.mis")
- SetOutputMode(2)
- SetMsgFilter(65535)
- StartCommandFiltering()
- ControlBar.SetDisable(871)
- DialogControl.SetDisable(20)
- ShopID = 733
- BuildingFactoryID = 734
- MineProductionSet = 0
- SteelMillProductionSet = 0
- LoggingCampProductionSet = 0
- SawMillProductionSet = 0
- SetState("Intro")
-
-
- // ============================================================================
- // INTRO
- // ============================================================================
- [STATE Intro]
-
- FirstTutorialTextID = 350
- LastTutorialTextID = 352
- ReturnState = 'SelectMine'
- SetState("Show_tutorial_text_serie")
-
- // ============================================================================
- // BUILD MINE
- // ============================================================================
- [STATE SelectMine]
- TutorialTextID = 302
- ReturnState = 'WaitForSelectMine'
- SetState("Show_tutorial_text")
-
-
- [STATE WaitForSelectMine]
- IF BuildDialog.IsOpen() == 1 AND
- BuildDialog.GetPanelID() == 1 AND
- BuildDialog.GetSelectionID() == 0
- THEN
- SetState("BuildMine")
- END
-
- [STATE BuildMine]
-
- TutorialTextID = 303
- ReturnState = 'WaitForBuildMine'
- SetState("Show_tutorial_text")
-
- [STATE WaitForBuildMine]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 4 AND
- NextCommand.GetInternType() == 0
-
- THEN
- NextCommand.Run()
- MineID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("BuildStoragePlace1")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildMine")
- END
- ELSE
- IF BuildDialog.IsOpen() <> 1 OR
- BuildDialog.GetPanelID() <> 1 OR
- BuildDialog.GetSelectionID() <> 0
- THEN
- SetState("SelectMine")
- END
- END
-
-
- // ============================================================================
- // BUILD STORAGE PLACE 1
- // ============================================================================
- [STATE BuildStoragePlace1]
-
- TutorialTextID = 306
- ReturnState = 'WaitForStoragePlace1'
- SetState("Show_tutorial_text")
-
- [STATE WaitForStoragePlace1]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 7
- THEN
- SetState("VerifyForStoragePlace1Location")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildStoragePlace1")
- END
- END
-
- [STATE VerifyForStoragePlace1Location]
- IF IsHighlighted(BuildingFactoryID) AND
- IsHighlighted(MineID)
- THEN
- NextCommand.Run()
- StoragePlace1ID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("BuildSteelMill")
- ELSE
- TutorialTextID = 400
- ReturnState = 'WaitForStoragePlace1'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // SET MINE PRODUCTION
- // ============================================================================
- [STATE SetMineProduction]
-
- TutorialTextID = 309
- ReturnState = 'WaitForMineProduction'
- SetState("Show_tutorial_text")
-
- [STATE WaitForMineProduction]
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_mine_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetMineProduction")
- END
- END
-
- [STATE Verify_mine_production]
- // Is it correct product & load ?
- IF NextCommand.GetInternType() == 0 AND
- NextCommand.GetInternType2() == 0.25
- THEN
- MineProductionSet = 1
- NextCommand.Run()
- ClearCommandQueue()
- SetState("SetSteelMillProduction")
-
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetMineProduction")
- END
-
-
- // ============================================================================
- // BUILD STEEL MILL
- // ============================================================================
- [STATE BuildSteelMill]
-
- TutorialTextID = 307
- ReturnState = 'WaitForSteelMill'
- SetState("Show_tutorial_text")
-
- [STATE WaitForSteelMill]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 4 AND
- NextCommand.GetInternType() == 10
- THEN
- SetState("VerifySteelMillLocation")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildSteelMill")
- END
- END
-
- [STATE VerifySteelMillLocation]
- IF IsHighlighted(StoragePlace1ID)
- THEN
- NextCommand.Run()
- SteelMillID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("SetMineProduction")
- ELSE
- TutorialTextID = 401
- ReturnState = 'WaitForSteelMill'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // SET STEEL MILL PRODUCTION
- // ============================================================================
- [STATE SetSteelMillProduction]
-
- TutorialTextID = 312
- ReturnState = 'WaitForSteelMillProduction'
- SetState("Show_tutorial_text")
-
- [STATE WaitForSteelMillProduction]
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_steel_mill_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetSteelMillProduction")
- END
- END
-
- [STATE Verify_steel_mill_production]
- // Is it correct product & load ?
- IF NextCommand.GetInternType() == 23 AND
- NextCommand.GetInternType2() == 0.50
- THEN
- SteelMillProductionSet = 1
- NextCommand.Run()
- ClearCommandQueue()
- SetState("BuildLoggingCamp")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetSteelMillProduction")
- END
-
-
- // ============================================================================
- // BUILD LOGGING CAMP
- // ============================================================================
- [STATE BuildLoggingCamp]
-
- TutorialTextID = 318
- ReturnState = 'WaitForLoggingCamp'
- SetState("Show_tutorial_text")
-
- [STATE WaitForLoggingCamp]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 4 AND
- NextCommand.GetInternType() == 2
- THEN
- SetState("VerifyLoggingCampLocation")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildLoggingCamp")
- END
- END
-
- [STATE VerifyLoggingCampLocation]
- IF IsHighlighted(StoragePlace1ID)
- THEN
- NextCommand.Run()
- LoggingCampID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("BuildSawMill")
- ELSE
- TutorialTextID = 401
- ReturnState = 'WaitForLoggingCamp'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // SET LOGGING CAMP PRODUCTION
- // ============================================================================
- [STATE SetLoggingCampProduction]
-
- TutorialTextID = 327
- ReturnState = 'WaitForLoggingCampProduction'
- SetState("Show_tutorial_text")
-
- [STATE WaitForLoggingCampProduction]
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_logging_camp_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetLoggingCampProduction")
- END
- END
-
- [STATE Verify_logging_camp_production]
- // Is it correct product & load ?
- IF NextCommand.GetInternType() == 7 AND
- NextCommand.GetInternType2() == 0.25
- THEN
- LoggingCampProductionSet = 1
- NextCommand.Run()
- ClearCommandQueue()
- SetState("SetSawMillProduction")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetLoggingCampProduction")
- END
-
-
- // ============================================================================
- // BUILD SAW MILL
- // ============================================================================
- [STATE BuildSawMill]
-
- TutorialTextID = 324
- ReturnState = 'WaitForSawMill'
- SetState("Show_tutorial_text")
-
- [STATE WaitForSawMill]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 4 AND
- NextCommand.GetInternType() == 9
- THEN
- SetState("VerifySawMillLocation")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildSawMill")
- END
- END
-
- [STATE VerifySawMillLocation]
- IF IsHighlighted(StoragePlace1ID)
- THEN
- NextCommand.Run()
- SawMillID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("SetLoggingCampProduction")
- ELSE
- TutorialTextID = 401
- ReturnState = 'WaitForSawMill'
- SetState("Show_tutorial_text")
- END
-
-
- // ============================================================================
- // SET SAW MILL PRODUCTION
- // ============================================================================
- [STATE SetSawMillProduction]
-
- TutorialTextID = 328
- ReturnState = 'WaitForSawMillProduction'
- SetState("Show_tutorial_text")
-
- [STATE WaitForSawMillProduction]
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_saw_mill_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetSawMillProduction")
- END
- END
-
- [STATE Verify_saw_mill_production]
- // Is it correct product & load ?
- IF NextCommand.GetInternType() == 21 AND
- NextCommand.GetInternType2() == 0.50
- THEN
- NextCommand.Run()
- ClearCommandQueue()
- SetState("StoragePlaceSettings")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetSawMillProduction")
- END
-
- // ============================================================================
- // STORAGE PLACE SETTINGS
- // ============================================================================
- [STATE StoragePlaceSettings]
-
- TutorialTextID = 330
- ReturnState = 'WaitForStoragePlaceDlg'
- SetState("Show_tutorial_text")
-
- [STATE WaitForStoragePlaceDlg]
-
- IF StorageDialog.IsOpen() == 1
- THEN
- FirstTutorialTextID = 331
- LastTutorialTextID = 333
- ReturnState = 'WaitForBuildingMaterialIndustry'
- SetState("Show_tutorial_text_serie")
- END
-
- [STATE WaitForBuildingMaterialIndustry]
-
- IF StorageDialog.GetCategory() == 19 AND
- StorageDialog.GetLevel(73) == 0
- THEN
- TutorialTextID = 335
- ReturnState = 'WaitForDialogAccept'
- SetState("Show_tutorial_text")
- ELSE
- IF StorageDialog.IsOpen() == 0
- THEN
- SetState("StoragePlaceSettings")
- END
- END
-
- [STATE WaitForLevel]
- IF StorageDialog.GetLevel(73) == 0
- THEN
- TutorialTextID = 339
- ReturnState = 'WaitForDialogAccept'
- SetState("Show_tutorial_text")
- ELSE
- IF StorageDialog.IsOpen() == 0
- THEN
- SetState("StoragePlaceSettings")
- ELSE
- IF StorageDialog.GetCategory() <> 19
- THEN
- SetState("WaitForStoragePlaceDlg")
- END
- END
- END
-
-
- [STATE WaitForDialogAccept]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 31
- THEN
- SetState("VerifyStoragePlaceSettings")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("WaitForStoragePlaceDlg")
- END
- ELSE
- IF StorageDialog.IsOpen() == 0
- THEN
- SetState("StoragePlaceSettings")
- END
- END
-
- [STATE VerifyStoragePlaceSettings]
- // Check the settings.
- IF ChangeStoragePlace.GetProductLevel(0) == 0.25 AND
- ChangeStoragePlace.GetProductLevel(7) == 0.25 AND
- ChangeStoragePlace.GetProductLevel(21) == 0.25 AND
- ChangeStoragePlace.GetProductLevel(23) == 0.25 AND
- ChangeStoragePlace.GetProductLevel(73) == 0.0
- THEN
- NextCommand.Run()
- SetState("SetBuildingFactoryProduction")
- ELSE
- SetState("StoragePlaceSettings")
- END
-
-
- // ============================================================================
- // BUILD STORAGE PLACE 2
- // ============================================================================
- [STATE BuildStoragePlace2]
-
- TutorialTextID = 342
- ReturnState = 'WaitForStoragePlace2'
- SetState("Show_tutorial_text")
-
- [STATE WaitForStoragePlace2]
- IF IsEnterState
- THEN
- ClearCommandQueue()
- END
-
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 7
- THEN
- SetState("VerifyForStoragePlace2Location")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("BuildStoragePlace2")
- END
- END
-
- [STATE VerifyForStoragePlace2Location]
- IF IsHighlighted(BuildingFactoryID) AND
- IsHighlighted(ShopID)
- THEN
- NextCommand.Run()
- StoragePlace2ID = User.GetLastBuildingBuilt()
- ClearCommandQueue()
- SetState("SetBuildingFactoryProduction")
- ELSE
- TutorialTextID = 403
- ReturnState = 'WaitForStoragePlace2'
- SetState("Show_tutorial_text")
- END
-
- // ============================================================================
- // CLICK ON FACTORY
- // ============================================================================
- [STATE ClickOnFactory]
- TutorialTextID = 334
- ReturnState = 'WaitForClickOnFactory'
- SetState("Show_tutorial_text")
-
- [STATE WaitForClickOnFactory]
- IF ProductionDialog.IsOpen() == 1
- THEN
- SetState("Shops")
- END
-
-
- // ============================================================================
- // SHOPS
- // ============================================================================
- [STATE Shops]
- TutorialTextID = 335
- ReturnState = 'WaitForShopDialog'
- SetState("Show_tutorial_text")
-
- [STATE WaitForShopDialog]
- IF ShopDialog.IsOpen() == 1
- THEN
- TutorialTextID = 336
- ReturnState = 'WaitForDemand'
- SetState("Show_tutorial_text")
- END
-
- [STATE WaitForDemand]
- IF ShopDialog.IsOpen() == 0
- THEN
- SetState("Shops")
- END
-
- IF ShopDialog.GetButtonPressed() == 2 AND
- ShopDialog.GetProduct() == 73
- THEN
- SetState("SetBuildingFactoryProduction")
- END
-
-
-
- // ============================================================================
- // SET PRODUCTION
- // ============================================================================
- [STATE SetBuildingFactoryProduction]
-
- TutorialTextID = 336
- ReturnState = 'WaitForBuildingFactoryProduction'
- SetState("Show_tutorial_text")
-
- [STATE WaitForBuildingFactoryProduction]
- // Is there a queued command ?
- IF GetCommandQueueLength() > 0
- THEN
- IF NextCommand.GetType() == 14
- THEN
- SetState("Verify_building_factory_production")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetBuildingFactoryProduction")
- END
- END
-
- [STATE Verify_building_factory_production]
- // Is it correct product & load ?
- IF NextCommand.GetInternType() == 73
- THEN
- NextCommand.Run()
- ClearCommandQueue()
- SetState("ShowMissionGoal")
- ELSE
- NextCommand.Cancel()
- ClearCommandQueue()
- SetState("SetBuildingFactoryProduction")
- END
-
- // ============================================================================
- // MISSION GOAL
- // ============================================================================
- [STATE ShowMissionGoal]
- FirstTutorialTextID = 340
- LastTutorialTextID = 341
- ReturnState = 'End'
- SetState("Show_tutorial_text_serie")
-
- // ============================================================================
- // END
- // ============================================================================
- [STATE End]
-
- IF IsEnterState
- THEN
- StopCommandFiltering()
- END
-
- // Otherwise do nothing ...
-
-
- // ============================================================================
- // HELPER STATES
- //
- // Here are some states, which are used to do repetitive tasks.
- // ============================================================================
- //-----------------------------------------------------------------------------
- // Show_tutorial_text
- // - Opens tutorial text
- // - Waits until it is closed
- // - Returns to the return state
- // ----------------------------------------------------------------------------
- [STATE Show_tutorial_text]
-
- IF IsEnterState
- THEN
- TutorialText.Show(TutorialTextID)
- ELSE
- IF TutorialText.IsOpen() == 0
- THEN
- SetState(ReturnState)
- END
- END
-
- //-----------------------------------------------------------------------------
- // Show_tutorial_text_serie
- // - Shows a serie of tutorial texts from FirstTutorialTextID to LastTutorialTextID
- // ----------------------------------------------------------------------------
- [STATE Show_tutorial_text_serie]
-
- IF IsEnterState
- THEN
- Local_i = FirstTutorialTextID
- TutorialText.Show(FirstTutorialTextID)
- ELSE
- IF TutorialText.IsOpen() == 0
- THEN
- Local_i = Local_i + 1
-
- IF Local_i > LastTutorialTextID
- THEN
- SetState(ReturnState)
- ELSE
- TutorialText.Show(Local_i)
- END
- END
- END
-